package com.extension.company.view.my.collect;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.extension.company.admin.R;
import com.extension.company.common.mvp.BaseFragment;
import com.extension.company.contract.my.FragmentCRecentlyContract;
import com.extension.company.model.entity.MyCollectionData;
import com.extension.company.presenter.my.FragmentCRecentlyPresenter;
import com.extension.company.view.adapter.MyCollectionAdapter;
import com.extension.company.common.widget.SlideRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 我的收藏---最近
 */
public class MyRecentlyCollectFragment extends BaseFragment<FragmentCRecentlyContract.View, FragmentCRecentlyPresenter> implements FragmentCRecentlyContract.View {

	@BindView(R.id.fragment_recently_slide_recycleview)
	SlideRecyclerView slideRecyclerView;

	private List<MyCollectionData> list = new ArrayList<>();
	private MyCollectionAdapter adapter;

	private Context context;

	@Override
	public void onAttach(Context context) {
		super.onAttach(context);
		this.context = context;
	}

	@Override
	public FragmentCRecentlyContract.View createView() {
		return this;
	}

	@Override
	public FragmentCRecentlyPresenter createPresenter() {
		return new FragmentCRecentlyPresenter();
	}

	@Override
	public void init() {

		for (int i = 0; i < 10; i++) {
			list.add(new MyCollectionData("名称" + i, "110"));
		}


		adapter = new MyCollectionAdapter(context, list);

		slideRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
		adapter.setOnDeleteClickListener(new MyCollectionAdapter.OnDeleteClickLister() {
			@Override
			public void onDeleteClick(View view, int position) {
				list.remove(position);
				adapter.notifyDataSetChanged();
				slideRecyclerView.closeMenu();
			}
		});
		slideRecyclerView.setAdapter(adapter);
	}

	@Override
	public int getMainLayout() {
//		return R.layout.base_recyclerview;
		return R.layout.fragment_crecently;
	}

	@Override
	public void showLoading() {

	}

	@Override
	public void hideLoading() {

	}

	@Override
	public void onError(Throwable throwable) {

	}

}
